/**   
 * @Title: AccountDetailListCommunicater.java 
 * @Package: com.esun.rabbit2.communicaters.accountdetail 
 * @Description: TODO(账户明细通讯类) 
 * @Author: Billy qigs@500wan.com   
 * @Date: 2011-8-2 上午10:13:38  
 * Copyright (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.accountdetail;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.Key;
import com.esun.model.AccountDetailListInfo;
import com.esun.model.UserInfo;
import com.esun.network.ServerCommunicater;
import com.esun.util.log.EDebug;

/**
 * @ClassName: AccountDetailListCommunicater
 * @Description: (账户明细通讯类)
 * @Author: Billy qigs@500wan.com
 * @Date: 2011-8-2 上午10:13:38
 */
public class AccountDetailListCommunicater extends ServerCommunicater {

	private final String USERSESSION = UserInfo.getUserInfo().getUserSession();
	private String msgServer;

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String str) {
		this.msgServer = str;
	}

	public boolean isGetAccountDetailList(String type, String pageno) throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {
		boolean isSucceed = false;
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(Config.PASER_MID, BussinessCode.MID_ACCOUNT_DETAIL));
		list.add(mapItem(Config.PASER_CK, USERSESSION));
		list.add(mapItem(Key.KEY_BUSISORT, type));
		list.add(mapItem(Key.KEY_PAGENO, pageno));
		list.add(mapItem(Key.KEY_PAGESIZE, Config.PAGE_SIZE));

		super.getServerResponse(list, true);
		EDebug.o(this, super.getServerMsg());
		setMsgServer(super.getErrorMSG());
		if (super.getState() == 100) {
			isSucceed = true;
		}

		return isSucceed;
	}

	public ArrayList<AccountDetailListInfo> getAccountDetailList() {
		ArrayList<AccountDetailListInfo> list = new ArrayList<AccountDetailListInfo>();

		for (int i = 0; i < super.getListResult().size(); i++) {
			AccountDetailListInfo info = new AccountDetailListInfo();

			info.setOpTime(super.getListResult().get(i).get(Key.KEY_OPTIME));
			info.setOpType(super.getListResult().get(i).get(Key.KEY_UP_INOUT));
			info.setMoney(super.getListResult().get(i).get(Key.KEY_UP_PAYMONEY));
			info.setNote(super.getListResult().get(i).get(Key.KEY_UO_NOTE));
			info.setLotType(super.getListResult().get(i).get(Key.KEY_UP_LOTTYPE));
			info.setBalance(super.getListResult().get(i).get(Key.KEY_UP_HASPAY));
			info.setPid(super.getListResult().get(i).get(Key.KEY_PID));
			info.setRemarks(super.getListResult().get(i).get(Key.KEY_UP_CONTENT));
			info.setTypeID(super.getListResult().get(i).get(Key.KEY_UP_BUSISORT));
			info.setServerTime(super.getListResult().get(i).get(Key.KEY_SERVERTIME));

			list.add(info);
		}

		return list;
	}

	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}
}
